﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using SinBiota.Model.Entities;

namespace SinBiota.Model.Business.OccurrenceServices.Datatypes
{

    public class TaxonSimilarityResult : IEnumerable<TaxonSimilarityResult.TaxonSimilarity>
    {
        public string OriginalRank { get; set; }
        public IDictionary<string,string > ClassificationDictionary { get; set; }
        public IList<TaxonSimilarity> TaxonSimilarities { get; set; }

        public class TaxonSimilarity
        {
            public int TaxonId { get; set; }
            public double Similarity { get; set; }
            public string Name { get; set; }
            public string Rank { get; set; }
            public double Score { get; set; }
        }

        public TaxonSimilarityResult()
        {
            TaxonSimilarities = new List<TaxonSimilarity>();
        }

       
        public void Add(TaxonSimilarity taxonSimilarity)
        {
            TaxonSimilarities.Add(taxonSimilarity);   
        }
        public void Add(int taxonId, double similarity, string name, string rank)
        {
            TaxonSimilarities.Add(new TaxonSimilarity{TaxonId = taxonId, Similarity = similarity, Name = name, Rank = rank});   
        }
        public void Combine(TaxonSimilarityResult result)
        {
            foreach (var taxonSimilarity in result)
            {
                Add(taxonSimilarity);
            }
            
        }
            public IEnumerator<TaxonSimilarity> GetEnumerator()
        {
            return TaxonSimilarities.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}